﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<DTTB.MV2.QUANLYNHANSUTIENLUONG.Models.FormBean.LoginHistoryModel.LoginHistoryForm>" %>

<%@ Import Namespace="DTTB.Common" %>
<%@ Import Namespace="DTTB.MV2.QUANLYNHANSUTIENLUONG.BussinessDelegate.CommonDelegate" %>
<%@ Import Namespace="DTTB.MV2.QUANLYNHANSUTIENLUONG.BussinessDelegate.CommonDelegate" %>
<%@ Import Namespace="DTTB.MV2.QUANLYNHANSUTIENLUONG.Models.LinQ.DanhMucChung" %>
<%@ Import Namespace="DTTB.MV2.QUANLYNHANSUTIENLUONG.Models.LinQ.LoginHistory" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc" %>
<%@ Import Namespace="DTTB.DTO" %>
<%@ Import Namespace="System.Web.Mvc.Html" %>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <%--<script type="text/javascript" language="javascript" src="<%= ResolveUrl("~/Content/Scripts/LoginHistory/NhatKySuDung.js") %>"></script>--%>
    
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            selectMenu("tienich-NhatKySuDung");
        });
    </script>

    <form id="form" method="post" action="#">
    <%=Html.Hidden("PageNumber", Model.PageNumber)%>

    <div class="box">
		<div class="title">
			<h5>&nbsp;Nhật ký sử dụng</h5>
		</div>
		
            <table class="table_outsite">
                <tr>
                    <td colspan="4">
                        <table cellspacing="0" cellpadding="0" class="table_list">
                            <tr class="title">
                                <td class="first" width="15%" align="center">
                                    <strong>Lần đăng nhập</strong>
                                </td>
                                <td>
                                    <strong>Ngày giờ vào</strong>
                                </td>
                                <td>
                                    <strong>Ngày giờ ra</strong>
                                </td>    
                                <td class="last">
                                    <strong>Thời gian sử dụng</strong>
                                </td>                                   
                            </tr>
                            <%--Danhd Muc Đơn vị List--%>

                            <%
                                
                            IList<TB_LoginHistory>LoginHistoryList = Model.LoginHistoryPagedList;
                            int i = 1;
                            var ngaygiovao = string.Empty;
                            var ngaygiora = string.Empty;
                                
                                
                            var giosudung = string.Empty;
                            var phutsudung = string.Empty;
                               
                            var giophutgiaysudung = string.Empty;
                            
                            foreach (TB_LoginHistory item in LoginHistoryList)
                            {
                                if (item.LoginDate != null)
                                {
                                    ngaygiovao =  String.Format("{0:hh:mm:ss tt dd/MM/yyyy}", item.LoginDate) + " - " + DateTimeExtension.ConvertDateTimeToDayOfWeek((DateTime)item.LoginDate);
                                }
                               
                                if (item.LogoutDate != null)
                                {
                                    ngaygiora = String.Format("{0:hh:mm:ss tt dd/MM/yyyy}", item.LogoutDate) + " - " + DateTimeExtension.ConvertDateTimeToDayOfWeek((DateTime)item.LogoutDate);
                                }
                                
                                if(item.UsedSeconds != null && item.UsedMinutes != null)
                                {
                                    giosudung = Convert.ToString(Convert.ToInt32(item.UsedMinutes)/60);
                                    phutsudung = Convert.ToString(Convert.ToInt32(item.UsedMinutes)%60);
                                    if(!string.IsNullOrEmpty(giosudung) && giosudung != "0")
                                    {
                                        giophutgiaysudung = giosudung + "h " + phutsudung + "' " + item.UsedSeconds + "s";
                                    }
                                    else
                                    {
                                        giophutgiaysudung = phutsudung + "' " + item.UsedSeconds + "s";
                                    }
                                }
                                
                            %>
                            <tr class="item_row" onclick="javascript:highlight(this);EditDonViAjax(<%=item.Id%>);">
                                <td class="first" align="center">
                                    <%=item.LanDangNhap%>
                                </td>
                                <td>
                                    <%=ngaygiovao%>
                                </td>
                                <td >
                                <%= ngaygiora%>
                                   
                                </td> 
                                <td class="last" style="text-align: right; padding-right:100px">
                                    <%= giophutgiaysudung %>
                                </td>
                            </tr>
                            <%}
                            %>
                            <tr class="border_bottom">
                                <td class="first" style="background: #DDDDDD">
                                </td>
                                <td class="last" colspan="7" align="right" style="background: #DDDDDD; padding-right: 10px">
                                    <%
                                    CommonDelegate CommonDelegate = new CommonDelegate();
                                    PagerOptions pagerOptions = new PagerOptions();
                                    CommonDelegate.ChangeTextPaging(pagerOptions, string.Empty);
                                    %>
                                    <div><%=Html.Pager(Model.LoginHistoryPagedList,pagerOptions) %></div>
                                    <%=Html.Hidden("PageNumber", Model.PageNumber)%>
                                </td>
                            </tr>
                            <%--dã xóa--%>
                        </table>
                    </td>
                </tr>
            </table>
           
       <%-- </div>--%>
    </div>
    <%--<%Html.EndForm(); %>--%>

    </form>
</asp:Content>
